var parkOrgchnJs = function(targetObj){
	this.sysUtils = new kendoUtils();
	this.targetObj = targetObj;
	var _this= this;
	JsonpAjax(baseApiPath+"facilities/devices",null,"json",function(result){
		if(result){
			_this.equs = result;
		}
	},false);
	this.init();
	return this;
};


var chargeBinfo = function(id, $list,type,init,$euqs) {
	if (id == undefined || !id) {
		this.id = "d-" + new Date().getTime();
	} else {
		this.id = id;
	}
	this.$list = $list;
	this.type = type;
	this.init = init;
	this.$euqs = $euqs;
	return this;
}
chargeBinfo.prototype = {
		addToList : function($p) {
			$p.createTr(this.$list.find("tbody"),this.id,null,this.type,this.init,this.$euqs);
		}
}
parkOrgchnJs.prototype={
		init:function(){
			var bindFieldArray = this.sysUtils.getBindFieldArray(this.targetObj);
			var bindFunctionArray = [
			                         {fName:"savechnOrg",fs:this.savechnOrg},
			                         {fName:"createRow",fs:this.createRow},
			                         {fName:"cancel",fs:parkTree.resetTree},
			                         {fName:"deleteRow",fs:this.deleteRow}];
			this.bindBaseModels = new bindBaseModel(null,bindFieldArray,bindFunctionArray,null);
			this.sysUtils.bindDoucment(this.bindBaseModels,this.targetObj,this);
			//通道类型
			var channelType = Utils.getModelValueByModelKey(BASIS.CHANNEL_TYPE.CHANNEL_TYPE_I);
			Utils.createDataDictDropDownList([{div:this.targetObj.find("#channelType"),parentModelKey:BASIS.CHANNEL_TYPE.ROOT,select:channelType}],this);
			//喇叭声音类型
			var voicegenders = Utils.getModelValueByModelKey(BASIS.VOICE_GENDER.MALE);
			Utils.createDataDictDropDownList([{div:this.targetObj.find("#voicegender"),parentModelKey:BASIS.VOICE_GENDER.ROOT,select:voicegenders}],this);
            this.initNumberWidget();
			this.loadChninfo();
//			this.showOff();
		},
		rangeChange:function (e) {
			$(e).next().text($(e).val());
		},
		loadChninfo:function (e) {
			var that = this;
			that.editResult = null;
			that.isEdit = null;
			if (!isEmpty(e)) {
                that = $(e.target).data("that");
            }
			var selectNode = zTree.getSelectedNodes()[0];
			var id = selectNode.id,level=selectNode.level,gpc=selectNode.gpc;
			var url = baseApiPath+"facilities/parkInfo";
			that.gpc = gpc;
            var type = gpc == 'chn_in' ? 'I' : 'E';
            that.type = type;
            if(type=='I'){
                that.targetObj.find("#chargeTips").remove();
                that.targetObj.find("#tollGate").remove();
			}
            if(id){
                that.isEdit = true;
                url += '?isEdit='+that.isEdit+'&organizationCode='+id;
            }else{
                that.isEdit = false;
                var node = zTree.getSelectedNodes()[0].getParentNode();
                id=node.id;
                url = baseApiPath+'facilities/addOrz?isEdit='+that.isEdit+'&pid='+node.id+'&lev='+level+'&gpc='+gpc;
            }
            JsonpAjax(baseApiPath+"facilities/areaOptions?chnCode="+id,null,"json",function(result){

				result.unshift({code:"0",name:"停车场场外"});
				Utils.createAjaxDropDownList({div:that.targetObj.find("#enter"),select:result,unshift:false},that);
				Utils.createAjaxDropDownList({div:that.targetObj.find("#leave"),select:result,unshift:false},that);
			},false);
            JsonpAjax(url,null,"json",function(result){
				that.editResult = result;
				that.sysUtils.setVariantBindFieldValue(result);
				that.setswitchCss();
				var drange = that.targetObj.find("#drange");
				var nrange = that.targetObj.find("#nrange");
				drange.next().text(drange.val());
				nrange.next().text(nrange.val());
                that.targetObj.find("#channelType").data("kendoDropDownList").enable(false);
                if(type=='I'){
                    that.targetObj.find("#enter").data("kendoDropDownList").enable(false);
                }else{
                    that.targetObj.find("#leave").data("kendoDropDownList").enable(false);
                }
			},false);
			if(that.isEdit){//编辑模式不给修改
				if( that.editResult && that.editResult.equs){
                    var equs = that.equs;
                    var item = that.editResult.equs;
                    var n = item.length;
                    for (var i = 0; i < n; i++) {
                        that.createTr(that.targetObj.find("#chn_list > tbody"),i,item[i],type,'edit',equs);
                    }
                }

			}else {
				var equs = that.equs;
				var n = equs.length;
				for (var i = 0; i < n; i++) {
					if(equs[i].standard == '1'){
						that.createTr(that.targetObj.find("#chn_list > tbody"),i,null,type,'init',equs);
					}
				}
			}
			parkTree.hideMask();
		},
		/**
		 * 初始化数字控件
		 */
		initNumberWidget:function(){
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_drange",3);
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_nrange",3);
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_night",'19:00');
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_daytime",'07:00');
			/*this.sysUtils.mvvmModel.set("equipmentManagements_basic_subnetMask",'255.255.255.0');
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_heartbeat",2);
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_port",5000);
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_clientIp",'192.168.0.100');
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_clientPort",5000);
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_serverIp",'192.168.0.101');
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_serverPort",5000);
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_centerIp",'192.168.0.102');
			this.sysUtils.mvvmModel.set("equipmentManagements_basic_centerPort",5000);*/
			this.sysUtils.mvvmModel.set("equipmentManagements_charge_ckRepeatIE","0,1");
			this.sysUtils.mvvmModel.set("equipmentManagements_charge_ckIE","0,1");
			this.sysUtils.mvvmModel.set("equipmentManagements_charge_fullStopIn","0,1");

		},
		setswitchCss:function () {
			var that = this;
			that.targetObj.find(".checkbox input[type='checkbox']").each(function () {
				$(this).click(function(){
					this.value= this.value !=1 ? 1 : 0;
                    //that.showOff(this);
					/*if(this.id == 'multizone'){
						that.showOff();
					}*/
				});
				if(this.value == 1){
					this.checked=true;
				}else{
					this.value=0;
					this.checked=false;
				}
				var bindS = $(this).attr('data-bind');
				that.sysUtils.mvvmModel.set(bindS.substr(bindS.indexOf(':')+1,bindS.length),this.value);
                //that.showOff(this);
			});
			that.targetObj.find("input[name=radios]").each(function () {
				$(this).click(function(){
					this.value= this.value !=1 ? 1 : 0;
				});
				if(this.value == 1){
					this.checked=true;
				}else{
					this.checked=false;
				}
			});

		},
		showOff:function (obj) {
            obj.value = obj.value=='on'?1:0;
            if(obj.value == 1){
                obj.checked=true;
            }else{
                obj.checked=false;
            }
			//this.targetObj.find('#multizone').val() == 'on' ? false : this.targetObj.find('#multizone').val() == 0 ? false : true;
		},
		changeColor:function (obj) {
			var id =obj.id;
			$('#pager a').each(function(){
				if(id=='5'){
					if(this.id =='5'){
						this.className='tabBg2-2';
					}else{
						this.className='tabBg1-1';
					}
				}else{
					if(this.id < id){
						this.className='tabBg1-1';
					}else if(this.id == id){
						this.className='tabBg1-2';
					}else{
						if(this.id=='5'){
							this.className ='tabBg2-3';
						}else{
							this.className ='tabBg1-3';
						}
					}
				}
			});
		},
		createTr : function($tbody, id,item,type,init,equs) {
			var _this = this;
			var tr = document.createElement("tr");
			var td_check = document.createElement("td");
			var td_name = document.createElement("td");
			var td_No = document.createElement("td");
			var td_ip = document.createElement("td");
			var td_port = document.createElement("td");
			var td_ctrlNo = document.createElement("td");
			var td_autoRecognition = document.createElement("td");

			var checkbox = document.createElement("input");
			checkbox.value = id;
			checkbox.tabindex = -1;
			checkbox.type = "checkbox";
			checkbox.name = "equ_ids";
			td_check.appendChild(checkbox);

			var name = document.createElement("select");
			name.name = "organizationName";
			name.flag = '';
			name.required = true;
			/*if(isEmpty(item)){  //表示添加行
				var defaultOption = document.createElement("option");
				defaultOption.innerHTML = "";
				name.appendChild(defaultOption);
			}
			var identVideo = Utils.getModelValueByModelKey(BASIS.DEVICE_CATEGORIES.DEVICE_CATEGORIES_0); //视频相机
			var identFlag = false;  //此处编辑的为识别相机增加主识别选项，否主识别选项为不可选状态
			$(equs).each(function (inx, itm) {
				var option = document.createElement("option");
				option.innerHTML = itm.deviceName;
				option.value = itm.deviceType;
				$(option).data("devJson",itm);
				if(isNotEmpt(item)){  //表示编辑行，只添加之前选中的设备，不允许修改
					if(item.equipmentManagements.basic.deviceid == itm.deviceType){
						name.appendChild(option);
						identFlag = itm.deviceCategories == identVideo?true:false;
						return;
					}
				}else{
					name.appendChild(option);
				}
			});
			 name.onchange = function () {
			 var devJson = $($(this).find('option:selected')).data("devJson");
			 if(devJson.deviceCategories == identVideo){
			 $(this).parents('tr').find('td:eq(6):first input').prop('disabled',false);
			 }else{
			 $(this).parents('tr').find('td:eq(6):first input').prop('disabled',true);
			 }
			 }*/
            /*var defaultOption = document.createElement("option");
            defaultOption.innerHTML = "";
            name.appendChild(defaultOption);*/
            var identVideo = Utils.getModelValueByModelKey(BASIS.DEVICE_CATEGORIES.DEVICE_CATEGORIES_0); //视频相机
            var identFlag = false;  //此处编辑的为识别相机增加主识别选项，否主识别选项为不可选状态
            $(equs).each(function (inx, itm) {
                if(init=='init' && itm.standard =='1'){
                    var option = document.createElement("option");
                    option.innerHTML = itm.deviceName;
                    option.value = itm.deviceType;
                    option.flag = itm.deviceCategories;
                    if ((item && item["equipmentManagements"] && item["equipmentManagements"]["basic"] && item["equipmentManagements"]["basic"]["deviceid"] == itm.deviceType) || (!item && inx==id)) {
                        option.setAttribute("selected", "selected");
                        name.flag = itm.deviceCategories;
                        name.appendChild(option);
                    }
                }else if(init=='edit'){
                        var option = document.createElement("option");
                        option.innerHTML = itm.deviceName;
                        option.value = itm.deviceType;
                        option.flag = itm.deviceCategories;
                        if (item && item["equipmentManagements"] && item["equipmentManagements"]["basic"] && item["equipmentManagements"]["basic"]["deviceid"] == itm.deviceType) {
                            option.setAttribute("selected", "selected");
                            name.flag = itm.deviceCategories;
                            identFlag = itm.deviceCategories == identVideo?true:false;
                            name.appendChild(option);
                            return;
                        }
                }else if(init=='addRow'){
                    var option = document.createElement("option");
                    option.innerHTML = itm.deviceName;
                    option.value = itm.deviceType;
                    option.flag = itm.deviceCategories;
                    if(inx==0){
                        option.setAttribute("selected", "selected");
                        name.flag = itm.deviceCategories;
                        identFlag = itm.deviceCategories == identVideo?true:false;
                    }
                    name.appendChild(option);
				}
            });
            name.onchange = function () {
                var flag = $(this).find('option:selected')[0].flag;
                name.flag = flag;
                if(flag == '0'){
                    $(this).parents('tr').find('td:eq(6):first input').prop('disabled',false);
                    $(this).parents('tr').find('td:eq(5):first input').prop('disabled',true);
                    $(this).parents('tr').find('td:eq(5):first input').prop('placeholder','');
                }else{
                    if(flag=='1'){
                        $(this).parents('tr').find('td:eq(5):first input').prop('disabled',true);
                        $(this).parents('tr').find('td:eq(5):first input').prop('placeholder','');
					}else {
                        $(this).parents('tr').find('td:eq(5):first input').prop('disabled', false);
                        $(this).parents('tr').find('td:eq(5):first input')[0].onblur=function () {
                            var thisOne = this;
                            var no = thisOne.value;
                            if(no!=''){
                                //页面校验
                                _this.targetObj.find("#chn_list > tbody tr").each(function (inx, itm) {
                                    var cols = $(itm).find("td");
                                    var ono = $(cols[5]).find("input").val();
                                    if($(cols[5]).find("input")[0]!=thisOne && ono == no){
                                        layer.tips('您已使用过此设备机号！！！',thisOne,{tipsMore: true,tips: [2, '#78BA32']});
                                        thisOne.value='';
                                        return;
                                    }
                                });
                                //数据库校验
                                JsonpAjax(baseApiPath+'facilities/checkCtrlNo?ctrlNo='+no+'&organizationCode='+$(thisOne).parent().prev().prev().prev()[0].children[0].value,null,"json",function(result){
                                    if(result.success){
                                        layer.tips('设备机号'+no+'已存在！！！',thisOne,{tipsMore: true,tips: [2, '#78BA32']});
                                        thisOne.value='';
                                    }
                                });
                            }
                        }
                        $(this).parents('tr').find('td:eq(5):first input').prop('placeholder', '99');
                    }
                    $(this).parents('tr').find('td:eq(6):first input').prop('disabled',true);
                }
            }
            if(name.options.length<1){
                return;
            }
			td_name.appendChild(name);
			var No = document.createElement("input");
			No.type = "text";
			No.value = item == undefined ? '' : item["organizationCode"] == undefined ? '' : item["organizationCode"];
			No.placeholder = '系统自动生成..';
			No.disabled="disabled";
			No.name = "organizationCode";
			td_No.appendChild(No);

			var IP = document.createElement("input");
			IP.type = "text";
			IP.maxlength="12";
			IP.value = item == undefined ? '' : item["equipmentManagements"] == undefined ? '' : item["equipmentManagements"]["basic"] == undefined ? '' : item["equipmentManagements"]["basic"]["ip"] == undefined ? '' : item["equipmentManagements"]["basic"]["ip"];
			IP.placeholder="192.168.0.1";
			IP.name = "equipmentManagements_basic_IP";
			IP.required = true;
			IP.pattern='^((?:(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d))))$';
			IP.setAttribute('data-validate','ip');
			IP.setAttribute('validationMessage','ip地址错误');
            IP.onblur = function () {
                var thisOne = this;
                var no = thisOne.value;
                if(no!=''){
                    //页面校验
                    _this.targetObj.find("#chn_list > tbody tr").each(function (inx, itm) {
                        var cols = $(itm).find("td");
                        var ono = $(cols[3]).find("input").val();
                        if($(cols[3]).find("input")[0]!=thisOne && ono == no){
                            layer.tips('您已使用过此IP地址！！！',thisOne,{tipsMore: true,tips: [2, '#78BA32']});
                            thisOne.value='';
                            return;
                        }
                    });
                    //数据库校验
                    JsonpAjax(baseApiPath+'facilities/checkDevIp?ip='+no+'&organizationCode='+$(thisOne).parent().prev()[0].children[0].value,null,"json",function(result){
                        if(result.success){
                            layer.tips('设备IP地址'+no+'已存在！！！',thisOne,{tipsMore: true,tips: [2, '#78BA32']});
                            thisOne.value='';
                        }
                    });
                }
            }
			td_ip.appendChild(IP);

			var PORT = document.createElement("input");
			PORT.type = "number";
			PORT.value = item == undefined ? '' : item["equipmentManagements"] == undefined ? '' : item["equipmentManagements"]["basic"] == undefined ? '' : item["equipmentManagements"]["basic"]["port"] == undefined ? '' : item["equipmentManagements"]["basic"]["port"];
			PORT.placeholder="65535";
			PORT.name = "equipmentManagements_basic_port";
			PORT.required = true;
			PORT.pattern = '(^[1-9]\\d{0,3}$)|(^[1-5]\\d{4}$)|(^6[0-4]\\d{3}$)|(^65[0-4]\\d{2}$)|(^655[0-2]\\d$)|(^6553[0-5]$)';
			PORT.setAttribute('data-validate','port');
			PORT.setAttribute('validationMessage','端口号错误');

			var ctrlNo = document.createElement("input");
			ctrlNo.type = "text";
            if(name.flag=='0' || name.flag == '1'){
                ctrlNo.disabled =  'disabled';
            }else{
                ctrlNo.value = item == undefined ? '' : item["equipmentManagements"] == undefined ? '' : item["equipmentManagements"]["basic"] == undefined ? '' : item["equipmentManagements"]["basic"]["deviceNumber"] == undefined ? '' : item["equipmentManagements"]["basic"]["deviceNumber"];
                ctrlNo.placeholder="99";
                ctrlNo.name = "equipmentManagements_basic_deviceNumber";
                ctrlNo.required = true;
                ctrlNo.pattern = '^([1-9]\\d{0}|[0-8]\\d{1}|9[0-9])$';
                ctrlNo.setAttribute('data-validate','number');
                ctrlNo.setAttribute('validationMessage','设备机号介于1到99');

                ctrlNo.onblur = function () {
                    var thisOne = this;
                    var no = thisOne.value;
                    if(no!=''){
                        //页面校验
                        _this.targetObj.find("#chn_list > tbody tr").each(function (inx, itm) {
                            var cols = $(itm).find("td");
                            var ono = $(cols[5]).find("input").val();
                            if($(cols[5]).find("input")[0]!=thisOne && ono == no){
                                layer.tips('您已使用过此设备机号！！！',thisOne,{tipsMore: true,tips: [2, '#78BA32']});
                                thisOne.value='';
                                return;
                            }
                        });
                        //数据库校验
                        JsonpAjax(baseApiPath+'facilities/checkCtrlNo?ctrlNo='+no+'&organizationCode='+$(thisOne).parent().prev().prev().prev()[0].children[0].value,null,"json",function(result){
                            if(result.success){
                                layer.tips('设备机号'+no+'已存在！！！',thisOne,{tipsMore: true,tips: [2, '#78BA32']});
                                thisOne.value='';
                            }
                        });
                    }
                }
            }

			var autoRecognition = document.createElement("input");
			autoRecognition.style.height="17px";
			autoRecognition.type = "radio";
			autoRecognition.value = item == undefined ? 0 : item["equipmentManagements"] == undefined ? 0 : item["equipmentManagements"]["basic"] == undefined ? 0 : item["equipmentManagements"]["basic"]["autoRecognition"] == undefined ? 0 : item["equipmentManagements"]["basic"]["autoRecognition"] == '0' ? 0 : 1;
			autoRecognition.checked = item == undefined ? false : item["equipmentManagements"] == undefined ? false : item["equipmentManagements"]["basic"] == undefined ? false : item["equipmentManagements"]["basic"]["autoRecognition"] == undefined ? false : item["equipmentManagements"]["basic"]["autoRecognition"] == '0' ? false : true;
			autoRecognition.name = "equipmentManagements_open_autoRecognition";
			autoRecognition.onclick = function (e) {
				this.value= this.value !=1 ? 1 : 0;
			}
			if(true != identFlag || isEmpty(item)){  //如果编辑状态下不是识别相机，或者不在编辑状态下，主识别都不启动
				autoRecognition.disabled =  "disabled";
				autoRecognition.checked= false;
			}
			td_autoRecognition.appendChild(autoRecognition);

			if(autoRecognition.disabled){
				if(ctrlNo.disabled){
                    PORT.addEventListener('keydown', function(e) {
                        if (e.keyCode == 9) {
                            if ($(this).parents("tr").next().length < 1) {
                                var $_no_input = $(this).parents("tr").find("select[name=organizationName]");
                                var _val = $_no_input.val();
                                if (_val == "" || _val == undefined || !_val) {
                                    e.returnValue = false;
                                    e.cancel = true;
                                    $_no_input.focus();
                                    return;
                                }
                                e.returnValue = false;
                                e.cancel = true;
                                new chargeBinfo(undefined, _this.targetObj.find("#chn_list"),type,'addRow',equs).addToList(_this);
                                _this.targetObj.find("#chn_list tbody tr:last select[name=organizationName]").focus();
                                return;
                            }
                        }
                    });
				}else{
                    ctrlNo.addEventListener('keydown', function(e) {
                        if (e.keyCode == 9) {
                            if ($(this).parents("tr").next().length < 1) {
                                var $_no_input = $(this).parents("tr").find("select[name=organizationName]");
                                var _val = $_no_input.val();
                                if (_val == "" || _val == undefined || !_val) {
                                    e.returnValue = false;
                                    e.cancel = true;
                                    $_no_input.focus();
                                    return;
                                }
                                e.returnValue = false;
                                e.cancel = true;
                                new chargeBinfo(undefined, _this.targetObj.find("#chn_list"),type,'addRow',equs).addToList(_this);
                                _this.targetObj.find("#chn_list tbody tr:last select[name=organizationName]").focus();
                                return;
                            }
                        }
                    });
				}
			}else{
                autoRecognition.addEventListener('keydown', function(e) {
                    if (e.keyCode == 9) {
                        if ($(this).parents("tr").next().length < 1) {
                            var $_no_input = $(this).parents("tr").find("select[name=organizationName]");
                            var _val = $_no_input.val();
                            if (_val == "" || _val == undefined || !_val) {
                                e.returnValue = false;
                                e.cancel = true;
                                $_no_input.focus();
                                return;
                            }
                            e.returnValue = false;
                            e.cancel = true;
                            new chargeBinfo(undefined, _this.targetObj.find("#chn_list"),type,'addRow',equs).addToList(_this);
                            _this.targetObj.find("#chn_list tbody tr:last select[name=organizationName]").focus();
                            return;
                        }
                    }
                });
			}
            td_port.appendChild(PORT);
            td_ctrlNo.appendChild(ctrlNo);


			tr.appendChild(td_check);
			tr.appendChild(td_name);
			tr.appendChild(td_No);
			tr.appendChild(td_ip);
			tr.appendChild(td_port);
			tr.appendChild(td_ctrlNo);
			tr.appendChild(td_autoRecognition);

			$tbody[0].appendChild(tr);
		},
		deleteRow : function(e) {
			var _this = this;
			if (!isEmpty(e)) {
				_this = $(e.target).data("that");
			}
			_this.targetObj.find("input[name=\"equ_ids\"]:checked").each(function(inx, itm) {
				$(itm).parents("tr").remove();
			});
		},
		createRow : function(e) {
			var _this = this;
			var selectNode = zTree.getSelectedNodes()[0];
			var gpc=selectNode.gpc;
			var type = gpc == 'chn_in' ? 'I' : 'E';
			if (!isEmpty(e)) {
				_this = $(e.target).data("that");
			}
			new chargeBinfo(undefined, _this.targetObj.find("#chn_list"),chnOrg.type,'addRow',chnOrg.equs).addToList(_this);
		},
		//保存通道信息
		savechnOrg:function(e){
			var that =  $(e.target).data("that");
			if(validityForm(that.targetObj)){
				var parkInfo = that.sysUtils.getBindDocJson();
				var dayTime = parkInfo["equipmentManagements_basic_daytime"];
				if(typeof dayTime == 'object'){
					parkInfo["equipmentManagements_basic_daytime"] = kendo.toString(dayTime,"HH:mm");
				}
				var night = parkInfo["equipmentManagements_basic_night"];
				if(typeof night == 'object'){
					parkInfo["equipmentManagements_basic_night"] = kendo.toString(night,"HH:mm");
				}
				var url = baseApiPath+"facilities/saveParkInfo?isEdit=" + that.isEdit;
				var sendJson=parkInfo;
				for(var o in parkInfo){
					if(o.indexOf('_') !=-1){
						var strArray = o.substring(o.indexOf('_')+1);
						var name = o.substring(0, o.indexOf('_'));
						var jsonA = {};
						jsonA[name] = that.recursionObjectName(strArray,parkInfo[o]) ;
						delete parkInfo[o];
						var sendJson =$.extend(true,parkInfo,jsonA);
					}
				}
				//封装设备数据
				var boundTable = function (calcheck,difcheck) {
					var jsonD= {equs:{}};
					var eqArr = new Array();
                    var deviceNumbers = new Array();
                    var ipNumbers = new Array();

					that.targetObj.find("#chn_list > tbody tr").each(function (inx, itm) {
						var cols = $(itm).find("td");
						if($(cols[1]).find("select").val() !='-1'){
							var deviceid = $(cols[1]).find("select").val();
							var deviceCategories = $(cols[1]).find("select")[0].flag;
							var name= $(cols[1]).find("select option:selected").text();
							var code = $(cols[2]).find("input").val();
							var ip = $(cols[3]).find("input").val();
							var port = $(cols[4]).find("input").val();
							var ctrlNo = $(cols[5]).find("input").val();
							var autoRecognition = $(cols[6]).find("input").prop("checked")?1:0;
							//var option = $(cols[1]).find("select option:selected")[0];
							if($(cols[5]).find("input")[0].disabled){
                                var jsonE= {name:name,code:code,ip:ip,port:port,autoRecognition:autoRecognition,deviceid:deviceid,deviceCategories:deviceCategories};
                            }else{
                                var jsonE= {name:name,code:code,ip:ip,port:port,deviceNumber:ctrlNo,autoRecognition:autoRecognition,deviceid:deviceid,deviceCategories:deviceCategories};
                            }
							eqArr.push(jsonE);
                            if($.inArray(ctrlNo,deviceNumbers)<0){
								return "设备列表设备机号:"+ctrlNo+"重复，请重新设置";
                            }
                            if($.inArray(ip,ipNumbers)<0){
                                return "设备列表设备IP地址:"+ip+"重复，请重新设置";
                            }
                            deviceNumbers.push(ctrlNo);
                            ipNumbers.push(ip);
						}
					});

					jsonD.equs=JSON.stringify(eqArr);
					//合并json对象
					sendJson = $.extend(true,sendJson,jsonD);
					return '';
				}
				var check = $('#multizone').val() == 0 ? false : true;
				if(!check){//
					delete sendJson['equipmentManagements']['basic']['leave'];
					delete sendJson['equipmentManagements']['basic']['enter'];
				}

				var hasMsg = boundTable();
				if(hasMsg!=''){
                    notification({title : "友情提示", message : hasMsg}, 'info');
                    return;
				}

				JsonpAjax(url,JSON.stringify(sendJson),"json",function(result){
                    that.sysUtils.setVariantBindFieldValue(result);
                    that.isEdit=true;
                    that.targetObj.find("#chn_list > tbody").empty();
                    if( result && result.equs){
                        var equs = that.equs;
                        var item = result.equs;
                        var n = item.length;
                        for (var i = 0; i < n; i++) {
                            that.createTr(that.targetObj.find("#chn_list > tbody"),i,item[i],'I','edit',equs);
                        }
                    }
                    parkTree.localUpdate(result);
                    var node = zTree.getSelectedNodes()[0];
                    parkTree.resetTree();
                    setTimeout(function() {
                        zTree.selectNode(node);
                    },1000);

				});
			}
		},
		recursionObjectName : function (strArray,val) {
			if (strArray.indexOf('_') == -1){
				var jsonC = {};
				jsonC[strArray]=val;
				return jsonC;
			}
			var name = strArray.substring(0, strArray.indexOf('_'));
			strArray = strArray.substring(strArray.indexOf('_')+1);
			var jsonB = {};
			jsonB[name] = this.recursionObjectName(strArray,val);
			return jsonB;
		}
}
